﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using My.ELibrary.Model.Search;
using My.ELibrary.Business.Search;
using My.ELibrary.Common;

public partial class Search_UC_ShowOtherResource : System.Web.UI.UserControl
{
    private int ModelId
    {
        get
        {
            if (Request["ModelId"] != null)
            {
                return int.Parse(Request["ModelId"].ToString());
            }
            return -1;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (ModelId == -1)
            return;
        ElibResOtherResourceModel book = ElibResOtherResourceBLL.GetInstance().SelectOne(ModelId);
        if (book != null)
        {
            ShowBookInfo(book);
        }
    }

    private void ShowBookInfo(ElibResOtherResourceModel otherRes)
    {
        if (otherRes == null)
            return;

        lblNameLocal.Text = EncodeForLabelShow(otherRes.NameLocal);
        lblNameEn.Text = EncodeForLabelShow(otherRes.NameEn);
        lblGroupOne.Text = otherRes.GroupOne != 0 ? otherRes.GroupOne.ToString() : string.Empty;
        lblGroupTwo.Text = otherRes.GroupTwo != 0 ? otherRes.GroupTwo.ToString() : string.Empty;
        lblGroupThree.Text = otherRes.GroupThree != 0 ? otherRes.GroupThree.ToString() : string.Empty;
        lblGroupFour.Text = otherRes.GroupFour != 0 ? otherRes.GroupFour.ToString() : string.Empty;
        lblSubject.Text = EncodeForLabelShow(otherRes.Subject);
        lblSummary.Text = EncodeForLabelShow(otherRes.Summary);
        lblKeyWords.Text = EncodeForLabelShow(otherRes.Keywords);
        lblHeadLine.Text = EncodeForLabelShow(otherRes.Headerline);
        lblAuthor1.Text = EncodeForLabelShow(otherRes.Author1);
        lblAuthor2.Text = EncodeForLabelShow(otherRes.Author2);
        lblAuthor3.Text = EncodeForLabelShow(otherRes.Author3);
        lblBookDate.Text = otherRes.NewspaperDate != MyType.NullForDateTime ? otherRes.NewspaperDate.ToString() : string.Empty;
        //lblBookDate.Text = otherRes.NewspaperDate.ToString();
        lblPublish.Text = EncodeForLabelShow(otherRes.Publisher);
        lblPublishDate.Text = otherRes.PublishedDate != MyType.NullForDateTime ? otherRes.PublishedDate.ToString() : string.Empty;
        //lblPublishDate.Text = otherRes.PublishedDate.ToString();
        lblPrice.Text = otherRes.Price != 0 ? otherRes.Price.ToString() : string.Empty;
        lblCatalogue.Text = EncodeForLabelShow(otherRes.CatalogueHtml);
    }

    private string EncodeForLabelShow(string strSourceFromDB)
    {
        if (!string.IsNullOrEmpty(strSourceFromDB))
        {
            return Server.HtmlDecode(strSourceFromDB);
        }
        return string.Empty;
    }
}
